package chapter9;


class Foo {
    public <T> Foo(T t) {
        System.out.println(t.getClass());
    }
}

/**
 * 泛型构造器
 */
public class GenericConstructor {
    public static void main(String[] args) {
        //传入String
        Foo f1 = new Foo("java");
        Foo f2 = new Foo(200);
        //这种语法也正确
        Foo f3 = new <String> Foo("python");
        //下边的代码错误，泛型指定String，实际传入Double
        //Foo f4 = new <String> Foo(12.5);
    }
}
